package com.example.a80205050.myapplication.MyActivity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.a80205050.myapplication.Dao.FlagDao;
import com.example.a80205050.myapplication.Modle.Tb_flag;

/**
 * Created by 80205050 on 2017/11/1.
 */

public class Accountflag extends Activity {
    EditText txtFlag;
    Button btnflagSaveButton,btnflagCancelButtton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.accountflag);
        txtFlag=(EditText)findViewById(R.id.txtFlag);
        btnflagSaveButton=(Button)findViewById(R.id.btnFlagSave);
        btnflagCancelButtton=(Button)findViewById(R.id.btnFlagCancel);
        btnflagSaveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String strFlag=txtFlag.getText().toString();
                if(!strFlag.isEmpty()){
                    FlagDao flagDao=new FlagDao(Accountflag.this);
                    Tb_flag tb_flag=new Tb_flag(flagDao.getMaxId()+1,strFlag);
                    flagDao.add(tb_flag);
                    Toast.makeText(Accountflag.this,"新增便签数据添加成功",Toast.LENGTH_LONG).show();
                }else{
                    Toast.makeText(Accountflag.this,"请输入便签",Toast.LENGTH_LONG).show();
                }

            }
        });
        btnflagCancelButtton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                txtFlag.setText(" ");//清空便签的文本框
            }
        });
    }
}
